﻿/*****************************************************************
 * Copyright (C) Newegg Corporation. All rights reserved.
 * 
 * Author       :  Bill Li (Bill.S.Li@newegg.com)
 * Create Date  :  
 * Usage        :  
 *
 * RevisionHistory
 * Date         Author               Description
 * 
*****************************************************************/
using System.Text.RegularExpressions;
using System;

namespace TemplateEngine
{
    /// <summary>
    /// 标记半节点实体类
    /// </summary>
    internal class TranslateHalfNode
    {
        public string _nodeStr;
        public int _nodeIdx;

        public bool IsStartNode
        {
            get
            {
                return _nodeStr.Substring(0, 2) != "</";
            }
        }

        public bool IsCompletedNode
        {
            get
            {
                return _nodeStr.IndexOf("/>") != -1;
            }
        }

        /// <summary>
        /// 节点命令名称
        /// </summary>
        public string TranslateCommand
        {
            get
            {
                string[] array = _nodeStr.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                string value = array[0];
                value = value.Replace("<tag:", string.Empty);
                value = value.Replace("</tag:", string.Empty);
                value = value.Replace("/>", string.Empty);
                value = value.Replace(">", string.Empty);

                return value;
            }
        }

        public TranslateHalfNode(string nodeStr, int nodeIdx)
        {
            this._nodeIdx = nodeIdx;
            this._nodeStr = nodeStr;
        }
    }
}
